package chapter2.No2_1_synchronized同步方法.fSynchronized锁重入;

/**
 * !
 *
 * @author liujian
 * @version 2016/11/11 0011
 */
public class TestObject {

    public synchronized void service1() {
        try {
            System.out.println("线程："+Thread.currentThread().getName()+" service1执行");
            Thread.sleep(1000);
            service2();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    public synchronized void service2() {
        try {
            System.out.println("线程："+Thread.currentThread().getName()+" service2执行");
            Thread.sleep(1000);
            service3();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    public synchronized void service3() {
        System.out.println("线程："+Thread.currentThread().getName()+" service3执行");
    }
}
